package com.breaktian.assemble.threadpool;

import android.support.annotation.NonNull;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by keke.tian on 2018/2/28.
 */

public class BackgroundThreadFactory implements ThreadFactory {
    private AtomicInteger count = new AtomicInteger(0);
    @Override
    public Thread newThread(@NonNull Runnable runnable) {
        Thread t = new Thread(runnable);
        String threadName = ThreadPool.class.getSimpleName() + count.addAndGet(1);
        System.out.println(threadName);
        t.setName(threadName);
        return t;
    }
}
